# Replication archive for 
# Coppock, Alexander, Donald P. Green, and Ethan Porter. 2022. 
# Does Digital Advertising Affect Vote Choice? Evidence from a Randomized Field Experiment 
# Research & Politics. 

rm(list = ls())
# setwd() to replication archive

library(tidyverse)

zip_code_level <- read_rds("CGP_2022_zip_code_level.rds")

zip_code_level %>% 
  ungroup %>% 
  filter(Z == 1) %>% 
  summarise(sum(vote_total_2018, na.rm = TRUE))


votes_generated <- 822783 * 0.007 * 2
cost <- 40000 + 60000
cost / votes_generated  

# That said, if one were to take the mean of our final Bayesian posterior (0.7 percentage points) at face value, 
# it would imply a cost per vote of \$8.68, a figure that compares favorably to other campaign tactics \citep{gerber_green_gotv}. 
# \footnote{This calculation is based on delivering advertisements to 822,783 voters living in targeted ZIP codes, 
# at a total cost of \$100,000, inclusive of production and distribution costs. 
# 100,000 / (822783 * 0.007 * 2) = 8.68.} 
